home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cocktail / cg.lha / cg / m2c / GramC.c < prev    next >
C/C++ Source or Header  |  1992-11-24  |  38KB  |  1,481 lines

  1. #include "SYSTEM_.h"
  2.  
  3. #ifndef DEFINITION_System
  4. #include "System.h"
  5. #endif
  6.  
  7. #ifndef DEFINITION_IO
  8. #include "IO.h"
  9. #endif
  10.  
  11. #ifndef DEFINITION_Tree
  12. #include "Tree.h"
  13. #endif
  14.  
  15. #ifndef DEFINITION_IO
  16. #include "IO.h"
  17. #endif
  18.  
  19. #ifndef DEFINITION_Strings
  20. #include "Strings.h"
  21. #endif
  22.  
  23. #ifndef DEFINITION_StringMem
  24. #include "StringMem.h"
  25. #endif
  26.  
  27. #ifndef DEFINITION_Idents
  28. #include "Idents.h"
  29. #endif
  30.  
  31. #ifndef DEFINITION_Texts
  32. #include "Texts.h"
  33. #endif
  34.  
  35. #ifndef DEFINITION_Sets
  36. #include "Sets.h"
  37. #endif
  38.  
  39. #ifndef DEFINITION_TreeC2
  40. #include "TreeC2.h"
  41. #endif
  42.  
  43. #ifndef DEFINITION_Tree
  44. #include "Tree.h"
  45. #endif
  46.  
  47. #ifndef DEFINITION_Strings
  48. #include "Strings.h"
  49. #endif
  50.  
  51. #ifndef DEFINITION_GramC
  52. #include "GramC.h"
  53. #endif
  54.  
  55. IO_tFile GramC_yyf;
  56. PROC GramC_Exit;
  57.  
  58. static Tree_tTree Node, ActClass, TheClass, TheAttr;
  59. static Idents_tIdent iOper, iLeft, iRight, iNone, iPrec, iRule;
  60. static SHORTCARD ActActionIndex, PrevActionIndex;
  61. static BOOLEAN IsImplicit;
  62. static Strings_tString s;
  63. static Tree_tTree GetBaseClass ARGS((Tree_tTree Class));
  64. static BOOLEAN IsLast ARGS((Tree_tTree Class, Tree_tTree Action));
  65. static void IsLast2 ARGS((Tree_tTree t, Tree_tTree Action, BOOLEAN *pFound, BOOLEAN *pLast));
  66. static void Prefix ARGS(());
  67. static void yyAbort ARGS((CHAR yyFunction[], LONGCARD ));
  68. static BOOLEAN yyIsEqual ARGS((BYTE yya[], LONGCARD , BYTE yyb[], LONGCARD ));
  69. struct S_3 {
  70.     union {
  71.         char dummy;
  72.     } U_1;
  73. };
  74. struct S_4 {
  75.     union {
  76.         char dummy;
  77.     } U_1;
  78. };
  79. static void ErrorActions ARGS((Tree_tTree t));
  80. struct S_5 {
  81.     union {
  82.         char dummy;
  83.     } U_1;
  84. };
  85. static void ScanVariant ARGS((Tree_tTree t));
  86. struct S_6 {
  87.     union {
  88.         char dummy;
  89.     } U_1;
  90. };
  91. static void ScanAttr ARGS((Tree_tTree t));
  92. struct S_7 {
  93.     union {
  94.         char dummy;
  95.     } U_1;
  96. };
  97. static void ParsVariant ARGS((Tree_tTree t));
  98. struct S_8 {
  99.     union {
  100.         char dummy;
  101.     } U_1;
  102. };
  103. static void GenExt ARGS((Tree_tTree t));
  104. struct S_9 {
  105.     union {
  106.         char dummy;
  107.     } U_1;
  108. };
  109. static void Token ARGS((Tree_tTree t));
  110. struct S_10 {
  111.     union {
  112.         char dummy;
  113.     } U_1;
  114. };
  115. static void RecordField ARGS((Tree_tTree t));
  116. struct S_11 {
  117.     union {
  118.         char dummy;
  119.     } U_1;
  120. };
  121. static void PrecDefs ARGS((Tree_tTree t));
  122. struct S_12 {
  123.     union {
  124.         char dummy;
  125.     } U_1;
  126. };
  127. static void Grammar ARGS((Tree_tTree t));
  128. struct S_13 {
  129.     union {
  130.         char dummy;
  131.     } U_1;
  132. };
  133. static void Rule ARGS((Tree_tTree t));
  134. struct S_14 {
  135.     union {
  136.         char dummy;
  137.     } U_1;
  138. };
  139. static void Implicit ARGS((Tree_tTree t));
  140. struct S_15 {
  141.     union {
  142.         char dummy;
  143.     } U_1;
  144. };
  145. static void WriteName ARGS((Idents_tIdent Name));
  146. struct S_16 {
  147.     union {
  148.         char dummy;
  149.     } U_1;
  150. };
  151. static void yyExit ARGS(());
  152.  
  153.  
  154. static Tree_tTree GetBaseClass
  155. # ifdef __STDC__
  156. (Tree_tTree Class)
  157. # else
  158. (Class)
  159. Tree_tTree Class;
  160. # endif
  161. {
  162.   while (Class->U_1.V_5.Class.BaseClass->U_1.V_1.Kind != Tree_NoClass) {
  163.     Class = Class->U_1.V_5.Class.BaseClass;
  164.   }
  165.   return Class;
  166. }
  167.  
  168. static BOOLEAN IsLast
  169. # ifdef __STDC__
  170. (Tree_tTree Class, Tree_tTree Action)
  171. # else
  172. (Class, Action)
  173. Tree_tTree Class, Action;
  174. # endif
  175. {
  176.   BOOLEAN Found, Last;
  177.  
  178.   IsLast2(Class, Action, &Found, &Last);
  179.   return Last;
  180. }
  181.  
  182. static void IsLast2
  183. # ifdef __STDC__
  184. (Tree_tTree t, Tree_tTree Action, BOOLEAN *pFound, BOOLEAN *pLast)
  185. # else
  186. (t, Action, pFound, pLast)
  187. Tree_tTree t, Action;
  188. BOOLEAN *pFound, *pLast;
  189. # endif
  190. {
  191.   BOOLEAN Found, Last;
  192.  
  193.   switch (t->U_1.V_1.Kind) {
  194.   case Tree_Class:;
  195.     IsLast2(t->U_1.V_5.Class.Attributes, Action, pFound, pLast);
  196.     if (*pFound || !*pLast) {
  197.       return;
  198.     }
  199.     IsLast2(t->U_1.V_5.Class.BaseClass, Action, pFound, pLast);
  200.     break;
  201.   case Tree_Child:;
  202.     IsLast2(t->U_1.V_9.Child.Next, Action, &Found, &Last);
  203.     *pFound = Found;
  204.     if (Found) {
  205.       *pLast = Last;
  206.     } else {
  207.       *pLast = FALSE;
  208.     }
  209.     break;
  210.   case Tree_Attribute:;
  211.     IsLast2(t->U_1.V_10.Attribute.Next, Action, pFound, pLast);
  212.     break;
  213.   case Tree_ActionPart:;
  214.     IsLast2(t->U_1.V_11.ActionPart.Next, Action, &Found, &Last);
  215.     *pFound = Found || Action == t;
  216.     if (Found) {
  217.       *pLast = Last;
  218.     } else {
  219.       *pLast = Last && Action == t;
  220.     }
  221.     break;
  222.   default :
  223.     *pFound = FALSE;
  224.     *pLast = TRUE;
  225.     break;
  226.   }
  227. }
  228.  
  229. static void Prefix
  230. # ifdef __STDC__
  231. ()
  232. # else
  233. ()
  234. # endif
  235. {
  236.   if (Tree_TreeRoot->U_1.V_26.Ag.ScannerName != Idents_NoIdent) {
  237.     Tree_WI(Tree_TreeRoot->U_1.V_26.Ag.ScannerName);
  238.     IO_WriteS(Tree_f, (STRING)"_", 1L);
  239.   }
  240. }
  241.  
  242. static void yyAbort
  243. # ifdef __STDC__
  244. (CHAR yyFunction[], LONGCARD O_1)
  245. # else
  246. (yyFunction, O_1)
  247. CHAR yyFunction[];
  248. LONGCARD O_1;
  249. # endif
  250. {
  251.   OPEN_ARRAY_LOCALS
  252.  
  253.   ALLOC_OPEN_ARRAYS(O_1 * sizeof(CHAR), 1)
  254.   COPY_OPEN_ARRAY(yyFunction, O_1, CHAR)
  255.   IO_WriteS((System_tFile)IO_StdError, (STRING)"Error: module GramC, routine ", 29L);
  256.   IO_WriteS((System_tFile)IO_StdError, yyFunction, O_1);
  257.   IO_WriteS((System_tFile)IO_StdError, (STRING)" failed", 7L);
  258.   IO_WriteNl((System_tFile)IO_StdError);
  259.   (*GramC_Exit)();
  260.   FREE_OPEN_ARRAYS
  261. }
  262.  
  263. static BOOLEAN yyIsEqual
  264. # ifdef __STDC__
  265. (BYTE yya[], LONGCARD O_3, BYTE yyb[], LONGCARD O_2)
  266. # else
  267. (yya, O_3, yyb, O_2)
  268. BYTE yya[];
  269. LONGCARD O_3;
  270. BYTE yyb[];
  271. LONGCARD O_2;
  272. # endif
  273. {
  274.   INTEGER yyi;
  275.   OPEN_ARRAY_LOCALS
  276.  
  277.   ALLOC_OPEN_ARRAYS(O_2 * sizeof(WORD) + O_3 * sizeof(WORD), 2)
  278.   COPY_OPEN_ARRAY(yyb, O_2, WORD)
  279.   COPY_OPEN_ARRAY(yya, O_3, WORD)
  280.   {
  281.     LONGINT B_1 = 0, B_2 = (INTEGER)(O_3 - 1);
  282.  
  283.     if (B_1 <= B_2)
  284.       for (yyi = B_1;; yyi += 1) {
  285.         if (yya[yyi] != yyb[yyi]) {
  286.           FREE_OPEN_ARRAYS
  287.           return FALSE;
  288.         }
  289.         if (yyi >= B_2) break;
  290.       }
  291.   }
  292.   FREE_OPEN_ARRAYS
  293.   return TRUE;
  294. }
  295.  
  296. void GramC_ParsSpec
  297. # ifdef __STDC__
  298. (Tree_tTree t)
  299. # else
  300. (t)
  301. Tree_tTree t;
  302. # endif
  303. {
  304.   struct S_3 yyTempo;
  305.  
  306.   if (t == Tree_NoTree) {
  307.     return;
  308.   }
  309.   if (t->U_1.V_1.Kind == Tree_Ag) {
  310.     {
  311.       register Tree_yAg *W_1 = &t->U_1.V_26.Ag;
  312.  
  313.       if (W_1->ScannerName != Idents_NoIdent) {
  314.         IO_WriteS(Tree_f, (STRING)"SCANNER ", 8L);
  315.         Tree_WI(W_1->ScannerName);
  316.       }
  317.       IO_WriteS(Tree_f, (STRING)" PARSER ", 8L);
  318.       Tree_WI(W_1->ParserName);
  319.       IO_WriteNl(Tree_f);
  320.       IO_WriteS(Tree_f, (STRING)"GLOBAL {", 8L);
  321.       IO_WriteNl(Tree_f);
  322.       Texts_WriteText(Tree_f, W_1->ParserCodes->U_1.V_12.Codes.Global);
  323.       Node = W_1->Modules;
  324.       while (Node->U_1.V_1.Kind == Tree_Module) {
  325.         Texts_WriteText(Tree_f, Node->U_1.V_43.Module.ParserCodes->U_1.V_12.Codes.Global);
  326.         Node = Node->U_1.V_43.Module.Next;
  327.       }
  328.       ParsVariant(W_1->Classes);
  329.       IO_WriteNl(Tree_f);
  330.       IO_WriteS(Tree_f, (STRING)"typedef union {", 15L);
  331.       IO_WriteNl(Tree_f);
  332.       IO_WriteS(Tree_f, (STRING)" ", 1L);
  333.       Prefix();
  334.       IO_WriteS(Tree_f, (STRING)"tScanAttribute Scan;", 20L);
  335.       IO_WriteNl(Tree_f);
  336.       Node = W_1->Classes;
  337.       while (Node->U_1.V_1.Kind == Tree_Class) {
  338.         {
  339.           register Tree_yClass *W_2 = &Node->U_1.V_5.Class;
  340.  
  341.           if (SET_IS_SUBSET1(SET_ELEM(Tree_Nonterminal) | SET_ELEM(Tree_Referenced) | SET_ELEM(Tree_HasAttributes), W_2->Properties)) {
  342.             if (IN(Tree_String, W_2->Properties) && !IN(Tree_HasSelector, W_2->Properties)) {
  343.               IO_WriteS(Tree_f, (STRING)" yy", 3L);
  344.               Tree_WN((LONGINT)W_2->Name);
  345.               IO_WriteS(Tree_f, (STRING)" /* ", 4L);
  346.               Tree_WE(W_2->Name);
  347.               IO_WriteS(Tree_f, (STRING)" */ yy", 6L);
  348.               Tree_WN((LONGINT)W_2->Name);
  349.               IO_WriteS(Tree_f, (STRING)";", 1L);
  350.               IO_WriteNl(Tree_f);
  351.             } else {
  352.               IO_WriteS(Tree_f, (STRING)" yy", 3L);
  353.               Tree_WI(W_2->Selector);
  354.               IO_WriteS(Tree_f, (STRING)" ", 1L);
  355.               Tree_WI(W_2->Selector);
  356.               IO_WriteS(Tree_f, (STRING)";", 1L);
  357.               IO_WriteNl(Tree_f);
  358.             }
  359.           }
  360.           Node = W_2->Next;
  361.         }
  362.       }
  363.       IO_WriteS(Tree_f, (STRING)"} tParsAttribute;", 17L);
  364.       IO_WriteNl(Tree_f);
  365.       IO_WriteS(Tree_f, (STRING)"}", 1L);
  366.       IO_WriteNl(Tree_f);
  367.       IO_WriteNl(Tree_f);
  368.       IO_WriteS(Tree_f, (STRING)"EXPORT {", 8L);
  369.       IO_WriteNl(Tree_f);
  370.       Texts_WriteText(Tree_f, W_1->ParserCodes->U_1.V_12.Codes.Export);
  371.       Node = W_1->Modules;
  372.       while (Node->U_1.V_1.Kind == Tree_Module) {
  373.         Texts_WriteText(Tree_f, Node->U_1.V_43.Module.ParserCodes->U_1.V_12.Codes.Export);
  374.         Node = Node->U_1.V_43.Module.Next;
  375.       }
  376.       IO_WriteS(Tree_f, (STRING)"}", 1L);
  377.       IO_WriteNl(Tree_f);
  378.       IO_WriteNl(Tree_f);
  379.       IO_WriteS(Tree_f, (STRING)"LOCAL {", 7L);
  380.       IO_WriteNl(Tree_f);
  381.       Texts_WriteText(Tree_f, W_1->ParserCodes->U_1.V_12.Codes.Local);
  382.       Node = W_1->Modules;
  383.       while (Node->U_1.V_1.Kind == Tree_Module) {
  384.         Texts_WriteText(Tree_f, Node->U_1.V_43.Module.ParserCodes->U_1.V_12.Codes.Local);
  385.         Node = Node->U_1.V_43.Module.Next;
  386.       }
  387.       IO_WriteS(Tree_f, (STRING)"}", 1L);
  388.       IO_WriteNl(Tree_f);
  389.       IO_WriteNl(Tree_f);
  390.       IO_WriteS(Tree_f, (STRING)"BEGIN {", 7L);
  391.       IO_WriteNl(Tree_f);
  392.       Texts_WriteText(Tree_f, W_1->ParserCodes->U_1.V_12.Codes.Begin);
  393.       Node = W_1->Modules;
  394.       while (Node->U_1.V_1.Kind == Tree_Module) {
  395.         Texts_WriteText(Tree_f, Node->U_1.V_43.Module.ParserCodes->U_1.V_12.Codes.Begin);
  396.         Node = Node->U_1.V_43.Module.Next;
  397.       }
  398.       IO_WriteS(Tree_f, (STRING)"}", 1L);
  399.       IO_WriteNl(Tree_f);
  400.       IO_WriteNl(Tree_f);
  401.       IO_WriteS(Tree_f, (STRING)"CLOSE {", 7L);
  402.       IO_WriteNl(Tree_f);
  403.       Texts_WriteText(Tree_f, W_1->ParserCodes->U_1.V_12.Codes.Close);
  404.       Node = W_1->Modules;
  405.       while (Node->U_1.V_1.Kind == Tree_Module) {
  406.         Texts_WriteText(Tree_f, Node->U_1.V_43.Module.ParserCodes->U_1.V_12.Codes.Close);
  407.         Node = Node->U_1.V_43.Module.Next;
  408.       }
  409.       IO_WriteS(Tree_f, (STRING)"}", 1L);
  410.       IO_WriteNl(Tree_f);
  411.       IO_WriteNl(Tree_f);
  412.       IO_WriteS(Tree_f, (STRING)"TOKEN", 5L);
  413.       IO_WriteNl(Tree_f);
  414.       IO_WriteNl(Tree_f);
  415.       Tree_ForallClasses(W_1->Classes, (Tree_ProcOfT)Token);
  416.       IO_WriteNl(Tree_f);
  417.       IO_WriteS(Tree_f, (STRING)"OPER", 4L);
  418.       IO_WriteNl(Tree_f);
  419.       IO_WriteNl(Tree_f);
  420.       PrecDefs(W_1->Precs);
  421.       IO_WriteNl(Tree_f);
  422.       IO_WriteS(Tree_f, (STRING)"RULE", 4L);
  423.       IO_WriteNl(Tree_f);
  424.       IO_WriteNl(Tree_f);
  425.       Tree_ForallClasses(W_1->Classes, (Tree_ProcOfT)GramC_ParsSpec);
  426.       return;
  427.     }
  428.   }
  429.   if (t->U_1.V_1.Kind == Tree_Class) {
  430.     {
  431.       register Tree_yClass *W_3 = &t->U_1.V_5.Class;
  432.  
  433.       if (SET_IS_SUBSET1(SET_ELEM(Tree_Nonterminal) | SET_ELEM(Tree_Referenced), W_3->Properties)) {
  434.         TheClass = t;
  435.         Grammar(t);
  436.       }
  437.       return;
  438.     }
  439.   }
  440. }
  441.  
  442. void GramC_ScanSpec
  443. # ifdef __STDC__
  444. (Tree_tTree t)
  445. # else
  446. (t)
  447. Tree_tTree t;
  448. # endif
  449. {
  450.   struct S_4 yyTempo;
  451.  
  452.   if (t == Tree_NoTree) {
  453.     return;
  454.   }
  455.   if (t->U_1.V_1.Kind == Tree_Ag) {
  456.     {
  457.       register Tree_yAg *W_4 = &t->U_1.V_26.Ag;
  458.  
  459.       IO_WriteS(Tree_f, (STRING)"c", 1L);
  460.       IO_WriteNl(Tree_f);
  461.       IO_WriteS(Tree_f, (STRING)"# if defined __STDC__ | defined __cplusplus", 43L);
  462.       IO_WriteNl(Tree_f);
  463.       IO_WriteS(Tree_f, (STRING)"# define ARGS(parameters)    parameters", 36L);
  464.       IO_WriteNl(Tree_f);
  465.       IO_WriteS(Tree_f, (STRING)"# else", 6L);
  466.       IO_WriteNl(Tree_f);
  467.       IO_WriteS(Tree_f, (STRING)"# define ARGS(parameters)    ()", 28L);
  468.       IO_WriteNl(Tree_f);
  469.       IO_WriteS(Tree_f, (STRING)"# endif", 7L);
  470.       IO_WriteNl(Tree_f);
  471.       IO_WriteNl(Tree_f);
  472.       Tree_ForallClasses(W_4->Classes, (Tree_ProcOfT)ScanVariant);
  473.       IO_WriteNl(Tree_f);
  474.       IO_WriteS(Tree_f, (STRING)"typedef union {", 15L);
  475.       IO_WriteNl(Tree_f);
  476.       IO_WriteS(Tree_f, (STRING)" tPosition Position;", 20L);
  477.       IO_WriteNl(Tree_f);
  478.       Tree_ForallClasses(W_4->Classes, (Tree_ProcOfT)ScanAttr);
  479.       IO_WriteS(Tree_f, (STRING)"} ", 2L);
  480.       Prefix();
  481.       IO_WriteS(Tree_f, (STRING)"tScanAttribute;", 15L);
  482.       IO_WriteNl(Tree_f);
  483.       IO_WriteNl(Tree_f);
  484.       IO_WriteS(Tree_f, (STRING)"extern void ", 12L);
  485.       Prefix();
  486.       IO_WriteS(Tree_f, (STRING)"ErrorAttribute ARGS((int Token, ", 32L);
  487.       Prefix();
  488.       IO_WriteS(Tree_f, (STRING)"tScanAttribute * pAttribute));", 30L);
  489.       IO_WriteNl(Tree_f);
  490.       IO_WriteS(Tree_f, (STRING)"%%", 2L);
  491.       IO_WriteNl(Tree_f);
  492.       IO_WriteS(Tree_f, (STRING)"void ", 5L);
  493.       Prefix();
  494.       IO_WriteS(Tree_f, (STRING)"ErrorAttribute", 14L);
  495.       IO_WriteNl(Tree_f);
  496.       IO_WriteS(Tree_f, (STRING)"# if defined __STDC__ | defined __cplusplus", 43L);
  497.       IO_WriteNl(Tree_f);
  498.       IO_WriteS(Tree_f, (STRING)" (int Token, ", 13L);
  499.       Prefix();
  500.       IO_WriteS(Tree_f, (STRING)"tScanAttribute * pAttribute)", 28L);
  501.       IO_WriteNl(Tree_f);
  502.       IO_WriteS(Tree_f, (STRING)"# else", 6L);
  503.       IO_WriteNl(Tree_f);
  504.       IO_WriteS(Tree_f, (STRING)" (Token, pAttribute) int Token; ", 32L);
  505.       Prefix();
  506.       IO_WriteS(Tree_f, (STRING)"tScanAttribute * pAttribute;", 28L);
  507.       IO_WriteNl(Tree_f);
  508.       IO_WriteS(Tree_f, (STRING)"# endif", 7L);
  509.       IO_WriteNl(Tree_f);
  510.       IO_WriteS(Tree_f, (STRING)"{", 1L);
  511.       IO_WriteNl(Tree_f);
  512.       IO_WriteS(Tree_f, (STRING)" pAttribute->Position = ", 24L);
  513.       Prefix();
  514.       IO_WriteS(Tree_f, (STRING)"Attribute.Position;", 19L);
  515.       IO_WriteNl(Tree_f);
  516.       IO_WriteS(Tree_f, (STRING)" switch (Token) {", 17L);
  517.       IO_WriteNl(Tree_f);
  518.       Tree_ForallClasses(W_4->Classes, (Tree_ProcOfT)ErrorActions);
  519.       IO_WriteS(Tree_f, (STRING)" }", 2L);
  520.       IO_WriteNl(Tree_f);
  521.       IO_WriteS(Tree_f, (STRING)"}", 1L);
  522.       IO_WriteNl(Tree_f);
  523.       IO_WriteS(Tree_f, (STRING)"%%", 2L);
  524.       IO_WriteNl(Tree_f);
  525.       Tree_ForallClasses(W_4->Classes, (Tree_ProcOfT)GramC_ScanSpec);
  526.       return;
  527.     }
  528.   }
  529.   if (t->U_1.V_1.Kind == Tree_Class) {
  530.     {
  531.       register Tree_yClass *W_5 = &t->U_1.V_5.Class;
  532.  
  533.       if (SET_IS_SUBSET1(SET_ELEM(Tree_Terminal) | SET_ELEM(Tree_Referenced), W_5->Properties)) {
  534.         Tree_WN((LONGINT)W_5->Code);
  535.         if (IN(Tree_HasAttributes, W_5->Properties)) {
  536.           IO_WriteS(Tree_f, (STRING)" S ", 3L);
  537.         } else {
  538.           IO_WriteS(Tree_f, (STRING)" N ", 3L);
  539.         }
  540.         if (IN(Tree_String, W_5->Properties) && !IN(Tree_HasSelector, W_5->Properties)) {
  541.           IO_WriteS(Tree_f, (STRING)"yy", 2L);
  542.           Tree_WN((LONGINT)W_5->Code);
  543.         } else {
  544.           Tree_WI(W_5->Selector);
  545.         }
  546.         IO_WriteS(Tree_f, (STRING)" ", 1L);
  547.         Tree_WI(W_5->Name);
  548.         IO_WriteNl(Tree_f);
  549.       }
  550.       return;
  551.     }
  552.   }
  553. }
  554.  
  555. static void ErrorActions
  556. # ifdef __STDC__
  557. (Tree_tTree t)
  558. # else
  559. (t)
  560. Tree_tTree t;
  561. # endif
  562. {
  563.   struct S_5 yyTempo;
  564.  
  565.   if (t == Tree_NoTree) {
  566.     return;
  567.   }
  568.   switch (t->U_1.V_1.Kind) {
  569.   case Tree_Class:;
  570.     {
  571.       register Tree_yClass *W_6 = &t->U_1.V_5.Class;
  572.  
  573.       if (SET_IS_SUBSET1(SET_ELEM(Tree_Terminal) | SET_ELEM(Tree_Referenced) | SET_ELEM(Tree_HasAttributes), W_6->Properties)) {
  574.         IO_WriteS(Tree_f, (STRING)" case /* ", 9L);
  575.         Tree_WE(W_6->Name);
  576.         IO_WriteS(Tree_f, (STRING)" */ ", 4L);
  577.         Tree_WN((LONGINT)W_6->Code);
  578.         IO_WriteS(Tree_f, (STRING)": ", 2L);
  579.         IO_WriteNl(Tree_f);
  580.         TheClass = t;
  581.         Tree_ForallAttributes(t, (Tree_ProcOfT)ErrorActions);
  582.         IO_WriteS(Tree_f, (STRING)" break;", 7L);
  583.         IO_WriteNl(Tree_f);
  584.       }
  585.       return;
  586.     }
  587.     break;
  588.   case Tree_ActionPart:;
  589.     {
  590.       register Tree_yActionPart *W_7 = &t->U_1.V_11.ActionPart;
  591.  
  592.       ErrorActions(W_7->Actions);
  593.       return;
  594.     }
  595.     break;
  596.   case Tree_Assign:;
  597.     {
  598.       register Tree_yAssign *W_8 = &t->U_1.V_36.Assign;
  599.  
  600.       ErrorActions(W_8->Results);
  601.       IO_WriteS(Tree_f, (STRING)"=", 1L);
  602.       ErrorActions(W_8->Arguments);
  603.       IO_WriteS(Tree_f, (STRING)";", 1L);
  604.       IO_WriteNl(Tree_f);
  605.       ErrorActions(W_8->Next);
  606.       return;
  607.     }
  608.     break;
  609.   case Tree_Copy:;
  610.     {
  611.       register Tree_yCopy *W_9 = &t->U_1.V_37.Copy;
  612.  
  613.       ErrorActions(W_9->Results);
  614.       IO_WriteS(Tree_f, (STRING)" = ", 3L);
  615.       ErrorActions(W_9->Arguments);
  616.       IO_WriteS(Tree_f, (STRING)";", 1L);
  617.       IO_WriteNl(Tree_f);
  618.       ErrorActions(W_9->Next);
  619.       return;
  620.     }
  621.     break;
  622.   case Tree_TargetCode:;
  623.     {
  624.       register Tree_yTargetCode *W_10 = &t->U_1.V_38.TargetCode;
  625.  
  626.       ErrorActions(W_10->Code);
  627.       IO_WriteS(Tree_f, (STRING)";", 1L);
  628.       IO_WriteNl(Tree_f);
  629.       ErrorActions(W_10->Next);
  630.       return;
  631.     }
  632.     break;
  633.   case Tree_Order:;
  634.     {
  635.       register Tree_yOrder *W_11 = &t->U_1.V_39.Order;
  636.  
  637.       ErrorActions(W_11->Next);
  638.       return;
  639.     }
  640.     break;
  641.   case Tree_Check:;
  642.     {
  643.       register Tree_yCheck *W_12 = &t->U_1.V_40.Check;
  644.  
  645.       if (W_12->Statement != Tree_NoTree) {
  646.         if (W_12->Condition != Tree_NoTree) {
  647.           IO_WriteS(Tree_f, (STRING)"if (", 4L);
  648.           ErrorActions(W_12->Condition);
  649.           IO_WriteS(Tree_f, (STRING)") ; else { ", 11L);
  650.           ErrorActions(W_12->Statement);
  651.           IO_WriteS(Tree_f, (STRING)"; }", 3L);
  652.           IO_WriteNl(Tree_f);
  653.         } else {
  654.           IO_WriteS(Tree_f, (STRING)"{ ", 2L);
  655.           ErrorActions(W_12->Statement);
  656.           IO_WriteS(Tree_f, (STRING)"; }", 3L);
  657.           IO_WriteNl(Tree_f);
  658.         }
  659.       } else {
  660.         IO_WriteS(Tree_f, (STRING)"(void) (", 8L);
  661.         ErrorActions(W_12->Condition);
  662.         IO_WriteS(Tree_f, (STRING)");", 2L);
  663.         IO_WriteNl(Tree_f);
  664.       }
  665.       ErrorActions(W_12->Next);
  666.       return;
  667.     }
  668.     break;
  669.   case Tree_Designator:;
  670.     {
  671.       register Tree_yDesignator *W_13 = &t->U_1.V_15.Designator;
  672.  
  673.       Tree_WI(W_13->Selector);
  674.       IO_WriteS(Tree_f, (STRING)":", 1L);
  675.       Tree_WI(W_13->Attribute);
  676.       ErrorActions(W_13->Next);
  677.       return;
  678.     }
  679.     break;
  680.   case Tree_Ident:;
  681.     {
  682.       register Tree_yIdent *W_14 = &t->U_1.V_16.Ident;
  683.  
  684.       TheAttr = Tree_IdentifyAttribute(TheClass, W_14->Attribute);
  685.       if (TheAttr != Tree_NoTree) {
  686.         IO_WriteS(Tree_f, (STRING)"pAttribute->", 12L);
  687.         if (W_14->Attribute == Tree_iPosition) {
  688.         } else if (IN(Tree_String, TheClass->U_1.V_5.Class.Properties) && !IN(Tree_HasSelector, TheClass->U_1.V_5.Class.Properties)) {
  689.           IO_WriteS(Tree_f, (STRING)"yy", 2L);
  690.           Tree_WN((LONGINT)TheClass->U_1.V_5.Class.Code);
  691.           IO_WriteS(Tree_f, (STRING)".", 1L);
  692.         } else {
  693.           Tree_WI(TheClass->U_1.V_5.Class.Selector);
  694.           IO_WriteS(Tree_f, (STRING)".", 1L);
  695.         }
  696.       }
  697.       Tree_WI(W_14->Attribute);
  698.       ErrorActions(W_14->Next);
  699.       return;
  700.     }
  701.     break;
  702.   case Tree_Any:;
  703.     {
  704.       register Tree_yAny *W_15 = &t->U_1.V_18.Any;
  705.  
  706.       StringMem_WriteString(Tree_f, W_15->Code);
  707.       ErrorActions(W_15->Next);
  708.       return;
  709.     }
  710.     break;
  711.   case Tree_Anys:;
  712.     {
  713.       register Tree_yAnys *W_16 = &t->U_1.V_19.Anys;
  714.  
  715.       ErrorActions(W_16->Layouts);
  716.       ErrorActions(W_16->Next);
  717.       return;
  718.     }
  719.     break;
  720.   case Tree_LayoutAny:;
  721.     {
  722.       register Tree_yLayoutAny *W_17 = &t->U_1.V_22.LayoutAny;
  723.  
  724.       StringMem_WriteString(Tree_f, W_17->Code);
  725.       ErrorActions(W_17->Next);
  726.       return;
  727.     }
  728.     break;
  729.   default :
  730.     break;
  731.   }
  732. }
  733.  
  734. static void ScanVariant
  735. # ifdef __STDC__
  736. (Tree_tTree t)
  737. # else
  738. (t)
  739. Tree_tTree t;
  740. # endif
  741. {
  742.   struct S_6 yyTempo;
  743.  
  744.   if (t == Tree_NoTree) {
  745.     return;
  746.   }
  747.   if (t->U_1.V_1.Kind == Tree_Class) {
  748.     {
  749.       register Tree_yClass *W_18 = &t->U_1.V_5.Class;
  750.  
  751.       if (SET_IS_SUBSET1(SET_ELEM(Tree_Terminal) | SET_ELEM(Tree_Referenced) | SET_ELEM(Tree_HasAttributes), W_18->Properties)) {
  752.         IO_WriteS(Tree_f, (STRING)"typedef struct { tPosition yyPos; ", 34L);
  753.         TheClass = t;
  754.         Tree_ForallAttributes(t, (Tree_ProcOfT)RecordField);
  755.         if (IN(Tree_String, W_18->Properties) && !IN(Tree_HasSelector, W_18->Properties)) {
  756.           IO_WriteS(Tree_f, (STRING)"} /* ", 5L);
  757.           Tree_WE(W_18->Name);
  758.           IO_WriteS(Tree_f, (STRING)" */ yy", 6L);
  759.           Tree_WN((LONGINT)W_18->Code);
  760.           IO_WriteS(Tree_f, (STRING)";", 1L);
  761.           IO_WriteNl(Tree_f);
  762.         } else {
  763.           IO_WriteS(Tree_f, (STRING)"} yy", 4L);
  764.           Tree_WI(W_18->Selector);
  765.           IO_WriteS(Tree_f, (STRING)";", 1L);
  766.           IO_WriteNl(Tree_f);
  767.         }
  768.       }
  769.       return;
  770.     }
  771.   }
  772. }
  773.  
  774. static void ScanAttr
  775. # ifdef __STDC__
  776. (Tree_tTree t)
  777. # else
  778. (t)
  779. Tree_tTree t;
  780. # endif
  781. {
  782.   struct S_7 yyTempo;
  783.  
  784.   if (t == Tree_NoTree) {
  785.     return;
  786.   }
  787.   if (t->U_1.V_1.Kind == Tree_Class) {
  788.     {
  789.       register Tree_yClass *W_19 = &t->U_1.V_5.Class;
  790.  
  791.       if (SET_IS_SUBSET1(SET_ELEM(Tree_Terminal) | SET_ELEM(Tree_Referenced) | SET_ELEM(Tree_HasAttributes), W_19->Properties)) {
  792.         if (IN(Tree_String, W_19->Properties) && !IN(Tree_HasSelector, W_19->Properties)) {
  793.           IO_WriteS(Tree_f, (STRING)" yy", 3L);
  794.           Tree_WN((LONGINT)W_19->Code);
  795.           IO_WriteS(Tree_f, (STRING)" /* ", 4L);
  796.           Tree_WE(W_19->Name);
  797.           IO_WriteS(Tree_f, (STRING)" */ yy", 6L);
  798.           Tree_WN((LONGINT)W_19->Code);
  799.           IO_WriteS(Tree_f, (STRING)";", 1L);
  800.           IO_WriteNl(Tree_f);
  801.         } else {
  802.           IO_WriteS(Tree_f, (STRING)" yy", 3L);
  803.           Tree_WI(W_19->Selector);
  804.           IO_WriteS(Tree_f, (STRING)" ", 1L);
  805.           Tree_WI(W_19->Selector);
  806.           IO_WriteS(Tree_f, (STRING)";", 1L);
  807.           IO_WriteNl(Tree_f);
  808.         }
  809.       }
  810.       return;
  811.     }
  812.   }
  813. }
  814.  
  815. static void ParsVariant
  816. # ifdef __STDC__
  817. (Tree_tTree t)
  818. # else
  819. (t)
  820. Tree_tTree t;
  821. # endif
  822. {
  823.   struct S_8 yyTempo;
  824.  
  825.   if (t == Tree_NoTree) {
  826.     return;
  827.   }
  828.   if (t->U_1.V_1.Kind == Tree_Class) {
  829.     {
  830.       register Tree_yClass *W_20 = &t->U_1.V_5.Class;
  831.  
  832.       if (SET_IS_SUBSET1(SET_ELEM(Tree_Nonterminal) | SET_ELEM(Tree_Referenced) | SET_ELEM(Tree_HasAttributes), W_20->Properties)) {
  833.         IO_WriteS(Tree_f, (STRING)"typedef struct { ", 17L);
  834.         TheClass = t;
  835.         Tree_ForallAttributes(W_20->Attributes, (Tree_ProcOfT)RecordField);
  836.         GenExt(W_20->Extensions);
  837.         if (IN(Tree_String, W_20->Properties) && !IN(Tree_HasSelector, W_20->Properties)) {
  838.           IO_WriteS(Tree_f, (STRING)"} /* ", 5L);
  839.           Tree_WE(W_20->Name);
  840.           IO_WriteS(Tree_f, (STRING)" */ yy", 6L);
  841.           Tree_WN((LONGINT)W_20->Name);
  842.           IO_WriteS(Tree_f, (STRING)";", 1L);
  843.           IO_WriteNl(Tree_f);
  844.         } else {
  845.           IO_WriteS(Tree_f, (STRING)"} yy", 4L);
  846.           Tree_WI(W_20->Selector);
  847.           IO_WriteS(Tree_f, (STRING)";", 1L);
  848.           IO_WriteNl(Tree_f);
  849.         }
  850.       }
  851.       ParsVariant(W_20->Next);
  852.       return;
  853.     }
  854.   }
  855. }
  856.  
  857. static void GenExt
  858. # ifdef __STDC__
  859. (Tree_tTree t)
  860. # else
  861. (t)
  862. Tree_tTree t;
  863. # endif
  864. {
  865.   struct S_9 yyTempo;
  866.  
  867.   if (t == Tree_NoTree) {
  868.     return;
  869.   }
  870.   if (t->U_1.V_1.Kind == Tree_Class) {
  871.     {
  872.       register Tree_yClass *W_21 = &t->U_1.V_5.Class;
  873.  
  874.       Tree_ForallAttributes(W_21->Attributes, (Tree_ProcOfT)RecordField);
  875.       GenExt(W_21->Extensions);
  876.       GenExt(W_21->Next);
  877.       return;
  878.     }
  879.   }
  880. }
  881.  
  882. static void Token
  883. # ifdef __STDC__
  884. (Tree_tTree t)
  885. # else
  886. (t)
  887. Tree_tTree t;
  888. # endif
  889. {
  890.   struct S_10 yyTempo;
  891.  
  892.   if (t == Tree_NoTree) {
  893.     return;
  894.   }
  895.   if (t->U_1.V_1.Kind == Tree_Class) {
  896.     {
  897.       register Tree_yClass *W_22 = &t->U_1.V_5.Class;
  898.  
  899.       if (SET_IS_SUBSET1(SET_ELEM(Tree_Terminal) | SET_ELEM(Tree_Referenced), W_22->Properties)) {
  900.         WriteName(W_22->Name);
  901.         IO_WriteS(Tree_f, (STRING)" = ", 3L);
  902.         Tree_WN((LONGINT)W_22->Code);
  903.         IO_WriteNl(Tree_f);
  904.       }
  905.       return;
  906.     }
  907.   }
  908. }
  909.  
  910. static void RecordField
  911. # ifdef __STDC__
  912. (Tree_tTree t)
  913. # else
  914. (t)
  915. Tree_tTree t;
  916. # endif
  917. {
  918.   struct S_11 yyTempo;
  919.  
  920.   if (t == Tree_NoTree) {
  921.     return;
  922.   }
  923.   if (t->U_1.V_1.Kind == Tree_Attribute) {
  924.     {
  925.       register Tree_yAttribute *W_23 = &t->U_1.V_10.Attribute;
  926.  
  927.       if ((Tree_NoCodeAttr & W_23->Properties) == 0X0L) {
  928.         if (IN(Tree_Nonterminal, TheClass->U_1.V_5.Class.Properties) || W_23->Name != Tree_iPosition) {
  929.           Tree_WI(W_23->Type);
  930.           IO_WriteS(Tree_f, (STRING)" ", 1L);
  931.           Tree_WI(W_23->Name);
  932.           IO_WriteS(Tree_f, (STRING)"; ", 2L);
  933.         }
  934.       }
  935.       return;
  936.     }
  937.   }
  938. }
  939.  
  940. static void PrecDefs
  941. # ifdef __STDC__
  942. (Tree_tTree t)
  943. # else
  944. (t)
  945. Tree_tTree t;
  946. # endif
  947. {
  948.   struct S_12 yyTempo;
  949.  
  950.   if (t == Tree_NoTree) {
  951.     return;
  952.   }
  953.   if (t->U_1.V_1.Kind == Tree_LeftAssoc) {
  954.     {
  955.       register Tree_yLeftAssoc *W_24 = &t->U_1.V_30.LeftAssoc;
  956.  
  957.       IO_WriteS(Tree_f, (STRING)"LEFT ", 5L);
  958.       PrecDefs(W_24->Names);
  959.       IO_WriteNl(Tree_f);
  960.       PrecDefs(W_24->Next);
  961.       return;
  962.     }
  963.   }
  964.   if (t->U_1.V_1.Kind == Tree_RightAssoc) {
  965.     {
  966.       register Tree_yRightAssoc *W_25 = &t->U_1.V_31.RightAssoc;
  967.  
  968.       IO_WriteS(Tree_f, (STRING)"RIGHT", 5L);
  969.       PrecDefs(W_25->Names);
  970.       IO_WriteNl(Tree_f);
  971.       PrecDefs(W_25->Next);
  972.       return;
  973.     }
  974.   }
  975.   if (t->U_1.V_1.Kind == Tree_NonAssoc) {
  976.     {
  977.       register Tree_yNonAssoc *W_26 = &t->U_1.V_32.NonAssoc;
  978.  
  979.       IO_WriteS(Tree_f, (STRING)"NONE ", 5L);
  980.       PrecDefs(W_26->Names);
  981.       IO_WriteNl(Tree_f);
  982.       PrecDefs(W_26->Next);
  983.       return;
  984.     }
  985.   }
  986.   if (t->U_1.V_1.Kind == Tree_Name) {
  987.     {
  988.       register Tree_yName *W_27 = &t->U_1.V_25.Name;
  989.  
  990.       IO_WriteS(Tree_f, (STRING)" ", 1L);
  991.       Tree_WI(W_27->Name);
  992.       PrecDefs(W_27->Next);
  993.       return;
  994.     }
  995.   }
  996. }
  997.  
  998. static void Grammar
  999. # ifdef __STDC__
  1000. (Tree_tTree t)
  1001. # else
  1002. (t)
  1003. Tree_tTree t;
  1004. # endif
  1005. {
  1006.   struct S_13 yyTempo;
  1007.  
  1008.   if (t == Tree_NoTree) {
  1009.     return;
  1010.   }
  1011.   if (t->U_1.V_1.Kind == Tree_Class) {
  1012.     {
  1013.       register Tree_yClass *W_28 = &t->U_1.V_5.Class;
  1014.  
  1015.       if (W_28->Extensions->U_1.V_1.Kind == Tree_NoClass) {
  1016.         {
  1017.           register Tree_yClass *W_29 = &TheClass->U_1.V_5.Class;
  1018.  
  1019.           if (IN(Tree_String, W_29->Properties)) {
  1020.             IO_WriteS(Tree_f, (STRING)"yy", 2L);
  1021.             Tree_WN((LONGINT)W_29->Name);
  1022.           } else {
  1023.             WriteName(W_29->Name);
  1024.           }
  1025.         }
  1026.         IO_WriteS(Tree_f, (STRING)" : ", 3L);
  1027.         ActClass = t;
  1028.         PrevActionIndex = 0;
  1029.         IsImplicit = FALSE;
  1030.         Tree_ForallAttributes(t, (Tree_ProcOfT)Rule);
  1031.         if (W_28->Prec != Idents_NoIdent) {
  1032.           IO_WriteS(Tree_f, (STRING)"PREC ", 5L);
  1033.           Tree_WI(W_28->Prec);
  1034.           IO_WriteS(Tree_f, (STRING)" ", 1L);
  1035.         }
  1036.         IO_WriteS(Tree_f, (STRING)".", 1L);
  1037.         IO_WriteNl(Tree_f);
  1038.         PrevActionIndex = 0;
  1039.         IsImplicit = TRUE;
  1040.         Tree_ForallAttributes(t, (Tree_ProcOfT)Implicit);
  1041.       } else {
  1042.         Rule(W_28->Extensions);
  1043.       }
  1044.       return;
  1045.     }
  1046.   }
  1047. }
  1048.  
  1049. static void Rule
  1050. # ifdef __STDC__
  1051. (Tree_tTree t)
  1052. # else
  1053. (t)
  1054. Tree_tTree t;
  1055. # endif
  1056. {
  1057.   struct S_14 yyTempo;
  1058.  
  1059.   if (t == Tree_NoTree) {
  1060.     return;
  1061.   }
  1062.   switch (t->U_1.V_1.Kind) {
  1063.   case Tree_Class:;
  1064.     {
  1065.       register Tree_yClass *W_30 = &t->U_1.V_5.Class;
  1066.  
  1067.       Grammar(t);
  1068.       Rule(W_30->Next);
  1069.       return;
  1070.     }
  1071.     break;
  1072.   case Tree_Child:;
  1073.     {
  1074.       register Tree_yChild *W_31 = &t->U_1.V_9.Child;
  1075.  
  1076.       if (SET_IS_SUBSET1(SET_ELEM(Tree_String) | SET_ELEM(Tree_Nonterminal), W_31->Class->U_1.V_5.Class.Properties)) {
  1077.         IO_WriteS(Tree_f, (STRING)"yy", 2L);
  1078.         Tree_WN((LONGINT)W_31->Type);
  1079.       } else {
  1080.         WriteName(W_31->Type);
  1081.       }
  1082.       IO_WriteS(Tree_f, (STRING)" ", 1L);
  1083.       return;
  1084.     }
  1085.     break;
  1086.   case Tree_ActionPart:;
  1087.     {
  1088.       register Tree_yActionPart *W_32 = &t->U_1.V_11.ActionPart;
  1089.  
  1090.       if (IsLast(ActClass, t)) {
  1091.         IO_WriteS(Tree_f, (STRING)"{", 1L);
  1092.         if (PrevActionIndex != 0) {
  1093.           Node = GetBaseClass(TheClass);
  1094.           {
  1095.             register Tree_yClass *W_33 = &Node->U_1.V_5.Class;
  1096.  
  1097.             if (IN(Tree_HasAttributes, W_33->Properties)) {
  1098.               IO_WriteS(Tree_f, (STRING)" $$.", 4L);
  1099.               if (IN(Tree_String, W_33->Properties)) {
  1100.                 IO_WriteS(Tree_f, (STRING)"yy", 2L);
  1101.                 Tree_WN((LONGINT)W_33->Name);
  1102.               } else {
  1103.                 Tree_WI(W_33->Name);
  1104.               }
  1105.               IO_WriteS(Tree_f, (STRING)" = $", 4L);
  1106.               Tree_WN((LONGINT)PrevActionIndex);
  1107.               IO_WriteS(Tree_f, (STRING)".", 1L);
  1108.               if (IN(Tree_String, W_33->Properties)) {
  1109.                 IO_WriteS(Tree_f, (STRING)"yy", 2L);
  1110.                 Tree_WN((LONGINT)W_33->Name);
  1111.               } else {
  1112.                 Tree_WI(W_33->Name);
  1113.               }
  1114.               IO_WriteS(Tree_f, (STRING)";", 1L);
  1115.               IO_WriteNl(Tree_f);
  1116.             }
  1117.           }
  1118.         }
  1119.         Rule(W_32->Actions);
  1120.         IO_WriteS(Tree_f, (STRING)"} ", 2L);
  1121.       } else {
  1122.         IO_WriteS(Tree_f, (STRING)"xx", 2L);
  1123.         Tree_WN((LONGINT)W_32->Name);
  1124.         IO_WriteS(Tree_f, (STRING)" ", 1L);
  1125.       }
  1126.       PrevActionIndex = W_32->ParsIndex;
  1127.       return;
  1128.     }
  1129.     break;
  1130.   case Tree_Assign:;
  1131.     {
  1132.       register Tree_yAssign *W_34 = &t->U_1.V_36.Assign;
  1133.  
  1134.       Rule(W_34->Results);
  1135.       IO_WriteS(Tree_f, (STRING)"=", 1L);
  1136.       Rule(W_34->Arguments);
  1137.       IO_WriteS(Tree_f, (STRING)";", 1L);
  1138.       IO_WriteNl(Tree_f);
  1139.       Rule(W_34->Next);
  1140.       return;
  1141.     }
  1142.     break;
  1143.   case Tree_Copy:;
  1144.     {
  1145.       register Tree_yCopy *W_35 = &t->U_1.V_37.Copy;
  1146.  
  1147.       Rule(W_35->Results);
  1148.       IO_WriteS(Tree_f, (STRING)" = ", 3L);
  1149.       Rule(W_35->Arguments);
  1150.       IO_WriteS(Tree_f, (STRING)";", 1L);
  1151.       IO_WriteNl(Tree_f);
  1152.       Rule(W_35->Next);
  1153.       return;
  1154.     }
  1155.     break;
  1156.   case Tree_TargetCode:;
  1157.     {
  1158.       register Tree_yTargetCode *W_36 = &t->U_1.V_38.TargetCode;
  1159.  
  1160.       Rule(W_36->Code);
  1161.       IO_WriteS(Tree_f, (STRING)";", 1L);
  1162.       IO_WriteNl(Tree_f);
  1163.       Rule(W_36->Next);
  1164.       return;
  1165.     }
  1166.     break;
  1167.   case Tree_Order:;
  1168.     {
  1169.       register Tree_yOrder *W_37 = &t->U_1.V_39.Order;
  1170.  
  1171.       Rule(W_37->Next);
  1172.       return;
  1173.     }
  1174.     break;
  1175.   case Tree_Check:;
  1176.     {
  1177.       register Tree_yCheck *W_38 = &t->U_1.V_40.Check;
  1178.  
  1179.       if (W_38->Statement != Tree_NoTree) {
  1180.         if (W_38->Condition != Tree_NoTree) {
  1181.           IO_WriteS(Tree_f, (STRING)"if (", 4L);
  1182.           Rule(W_38->Condition);
  1183.           IO_WriteS(Tree_f, (STRING)") ; else { ", 11L);
  1184.           Rule(W_38->Statement);
  1185.           IO_WriteS(Tree_f, (STRING)"; }", 3L);
  1186.           IO_WriteNl(Tree_f);
  1187.         } else {
  1188.           IO_WriteS(Tree_f, (STRING)"{ ", 2L);
  1189.           Rule(W_38->Statement);
  1190.           IO_WriteS(Tree_f, (STRING)"; }", 3L);
  1191.         }
  1192.       } else {
  1193.         IO_WriteS(Tree_f, (STRING)"(void) (", 8L);
  1194.         Rule(W_38->Condition);
  1195.         IO_WriteS(Tree_f, (STRING)");", 2L);
  1196.         IO_WriteNl(Tree_f);
  1197.       }
  1198.       Rule(W_38->Next);
  1199.       return;
  1200.     }
  1201.     break;
  1202.   case Tree_Designator:;
  1203.     {
  1204.       register Tree_yDesignator *W_39 = &t->U_1.V_15.Designator;
  1205.  
  1206.       TheAttr = Tree_IdentifyAttribute(ActClass, W_39->Selector);
  1207.       if (TheAttr != Tree_NoTree) {
  1208.         Node = TheAttr->U_1.V_9.Child.Class;
  1209.         if (Node != Tree_NoTree) {
  1210.           IO_WriteS(Tree_f, (STRING)"$", 1L);
  1211.           if (!IsImplicit) {
  1212.             Tree_WN((LONGINT)TheAttr->U_1.V_9.Child.ParsIndex);
  1213.           } else {
  1214.             Tree_WN((LONGINT)(SHORTINT)(TheAttr->U_1.V_9.Child.ParsIndex + 1 - ActActionIndex));
  1215.           }
  1216.           if (IN(Tree_Nonterminal, Node->U_1.V_5.Class.Properties)) {
  1217.             Node = GetBaseClass(Node);
  1218.             if (IN(Tree_String, Node->U_1.V_5.Class.Properties) && !IN(Tree_HasSelector, Node->U_1.V_5.Class.Properties)) {
  1219.               IO_WriteS(Tree_f, (STRING)".yy", 3L);
  1220.               Tree_WN((LONGINT)Node->U_1.V_5.Class.Name);
  1221.             } else {
  1222.               IO_WriteS(Tree_f, (STRING)".", 1L);
  1223.               Tree_WI(Node->U_1.V_5.Class.Name);
  1224.             }
  1225.           } else {
  1226.             IO_WriteS(Tree_f, (STRING)".Scan", 5L);
  1227.             if (W_39->Attribute == Tree_iPosition) {
  1228.             } else if (IN(Tree_String, Node->U_1.V_5.Class.Properties) && !IN(Tree_HasSelector, Node->U_1.V_5.Class.Properties)) {
  1229.               IO_WriteS(Tree_f, (STRING)".yy", 3L);
  1230.               Tree_WN((LONGINT)Node->U_1.V_5.Class.Code);
  1231.             } else {
  1232.               IO_WriteS(Tree_f, (STRING)".", 1L);
  1233.               Tree_WI(Node->U_1.V_5.Class.Selector);
  1234.             }
  1235.           }
  1236.           IO_WriteS(Tree_f, (STRING)".", 1L);
  1237.           Tree_WI(W_39->Attribute);
  1238.         } else {
  1239.           Tree_WI(W_39->Selector);
  1240.           IO_WriteS(Tree_f, (STRING)":", 1L);
  1241.           Tree_WI(W_39->Attribute);
  1242.         }
  1243.       } else {
  1244.         Tree_WI(W_39->Selector);
  1245.         IO_WriteS(Tree_f, (STRING)":", 1L);
  1246.         Tree_WI(W_39->Attribute);
  1247.       }
  1248.       Rule(W_39->Next);
  1249.       return;
  1250.     }
  1251.     break;
  1252.   case Tree_Ident:;
  1253.     {
  1254.       register Tree_yIdent *W_40 = &t->U_1.V_16.Ident;
  1255.  
  1256.       TheAttr = Tree_IdentifyAttribute(ActClass, W_40->Attribute);
  1257.       Node = GetBaseClass(TheClass);
  1258.       if (TheAttr != Tree_NoTree) {
  1259.         if (IN(Tree_String, Node->U_1.V_5.Class.Properties) && !IN(Tree_HasSelector, Node->U_1.V_5.Class.Properties)) {
  1260.           IO_WriteS(Tree_f, (STRING)"$$.yy", 5L);
  1261.           Tree_WN((LONGINT)Node->U_1.V_5.Class.Name);
  1262.           IO_WriteS(Tree_f, (STRING)".", 1L);
  1263.           Tree_WI(W_40->Attribute);
  1264.         } else {
  1265.           IO_WriteS(Tree_f, (STRING)"$$.", 3L);
  1266.           Tree_WI(Node->U_1.V_5.Class.Name);
  1267.           IO_WriteS(Tree_f, (STRING)".", 1L);
  1268.           Tree_WI(W_40->Attribute);
  1269.         }
  1270.       } else {
  1271.         Tree_WI(W_40->Attribute);
  1272.       }
  1273.       Rule(W_40->Next);
  1274.       return;
  1275.     }
  1276.     break;
  1277.   case Tree_Any:;
  1278.     {
  1279.       register Tree_yAny *W_41 = &t->U_1.V_18.Any;
  1280.  
  1281.       StringMem_WriteString(Tree_f, W_41->Code);
  1282.       Rule(W_41->Next);
  1283.       return;
  1284.     }
  1285.     break;
  1286.   case Tree_Anys:;
  1287.     {
  1288.       register Tree_yAnys *W_42 = &t->U_1.V_19.Anys;
  1289.  
  1290.       Rule(W_42->Layouts);
  1291.       Rule(W_42->Next);
  1292.       return;
  1293.     }
  1294.     break;
  1295.   case Tree_LayoutAny:;
  1296.     {
  1297.       register Tree_yLayoutAny *W_43 = &t->U_1.V_22.LayoutAny;
  1298.  
  1299.       StringMem_WriteString(Tree_f, W_43->Code);
  1300.       Rule(W_43->Next);
  1301.       return;
  1302.     }
  1303.     break;
  1304.   default :
  1305.     break;
  1306.   }
  1307. }
  1308.  
  1309. static void Implicit
  1310. # ifdef __STDC__
  1311. (Tree_tTree t)
  1312. # else
  1313. (t)
  1314. Tree_tTree t;
  1315. # endif
  1316. {
  1317.   struct S_15 yyTempo;
  1318.  
  1319.   if (t == Tree_NoTree) {
  1320.     return;
  1321.   }
  1322.   if (t->U_1.V_1.Kind == Tree_ActionPart) {
  1323.     {
  1324.       register Tree_yActionPart *W_44 = &t->U_1.V_11.ActionPart;
  1325.  
  1326.       if (!IN(Tree_Generated, W_44->Properties) && !IsLast(ActClass, t)) {
  1327.         INCL(W_44->Properties, Tree_Generated);
  1328.         ActActionIndex = W_44->ParsIndex;
  1329.         IO_WriteS(Tree_f, (STRING)"xx", 2L);
  1330.         Tree_WN((LONGINT)W_44->Name);
  1331.         IO_WriteS(Tree_f, (STRING)" : {", 4L);
  1332.         if (PrevActionIndex != 0) {
  1333.           Node = GetBaseClass(TheClass);
  1334.           {
  1335.             register Tree_yClass *W_45 = &Node->U_1.V_5.Class;
  1336.  
  1337.             if (IN(Tree_HasAttributes, W_45->Properties)) {
  1338.               IO_WriteS(Tree_f, (STRING)" $$.", 4L);
  1339.               if (IN(Tree_String, W_45->Properties)) {
  1340.                 IO_WriteS(Tree_f, (STRING)"yy", 2L);
  1341.                 Tree_WN((LONGINT)W_45->Name);
  1342.               } else {
  1343.                 Tree_WI(W_45->Name);
  1344.               }
  1345.               IO_WriteS(Tree_f, (STRING)" = $", 4L);
  1346.               Tree_WN((LONGINT)(SHORTINT)(PrevActionIndex + 1 - ActActionIndex));
  1347.               IO_WriteS(Tree_f, (STRING)".", 1L);
  1348.               if (IN(Tree_String, W_45->Properties)) {
  1349.                 IO_WriteS(Tree_f, (STRING)"yy", 2L);
  1350.                 Tree_WN((LONGINT)W_45->Name);
  1351.               } else {
  1352.                 Tree_WI(W_45->Name);
  1353.               }
  1354.               IO_WriteS(Tree_f, (STRING)";", 1L);
  1355.               IO_WriteNl(Tree_f);
  1356.             }
  1357.           }
  1358.         }
  1359.         Rule(W_44->Actions);
  1360.         IO_WriteS(Tree_f, (STRING)"} .", 3L);
  1361.         IO_WriteNl(Tree_f);
  1362.       }
  1363.       PrevActionIndex = W_44->ParsIndex;
  1364.       return;
  1365.     }
  1366.   }
  1367. }
  1368.  
  1369. static void WriteName
  1370. # ifdef __STDC__
  1371. (Idents_tIdent Name)
  1372. # else
  1373. (Name)
  1374. Idents_tIdent Name;
  1375. # endif
  1376. {
  1377.   struct S_16 yyTempo;
  1378.  
  1379.   if (Name == iOper) {
  1380.     IO_WriteS(Tree_f, (STRING)"\\", 1L);
  1381.     Tree_WI(Name);
  1382.     return;
  1383.   }
  1384.   if (Name == iLeft) {
  1385.     IO_WriteS(Tree_f, (STRING)"\\", 1L);
  1386.     Tree_WI(Name);
  1387.     return;
  1388.   }
  1389.   if (Name == iRight) {
  1390.     IO_WriteS(Tree_f, (STRING)"\\", 1L);
  1391.     Tree_WI(Name);
  1392.     return;
  1393.   }
  1394.   if (Name == iNone) {
  1395.     IO_WriteS(Tree_f, (STRING)"\\", 1L);
  1396.     Tree_WI(Name);
  1397.     return;
  1398.   }
  1399.   if (Name == iPrec) {
  1400.     IO_WriteS(Tree_f, (STRING)"\\", 1L);
  1401.     Tree_WI(Name);
  1402.     return;
  1403.   }
  1404.   if (Name == iRule) {
  1405.     IO_WriteS(Tree_f, (STRING)"\\", 1L);
  1406.     Tree_WI(Name);
  1407.     return;
  1408.   }
  1409.   Tree_WI(Name);
  1410.   return;
  1411. }
  1412.  
  1413. void GramC_BeginGramC
  1414. # ifdef __STDC__
  1415. ()
  1416. # else
  1417. ()
  1418. # endif
  1419. {
  1420.   Strings_ArrayToString((STRING)"OPER", 4L, &s);
  1421.   iOper = Idents_MakeIdent(&s);
  1422.   Strings_ArrayToString((STRING)"RIGHT", 5L, &s);
  1423.   iRight = Idents_MakeIdent(&s);
  1424.   Strings_ArrayToString((STRING)"LEFT", 4L, &s);
  1425.   iLeft = Idents_MakeIdent(&s);
  1426.   Strings_ArrayToString((STRING)"NONE", 4L, &s);
  1427.   iNone = Idents_MakeIdent(&s);
  1428.   Strings_ArrayToString((STRING)"PREC", 4L, &s);
  1429.   iPrec = Idents_MakeIdent(&s);
  1430.   Strings_ArrayToString((STRING)"RULE", 4L, &s);
  1431.   iRule = Idents_MakeIdent(&s);
  1432. }
  1433.  
  1434. void GramC_CloseGramC
  1435. # ifdef __STDC__
  1436. ()
  1437. # else
  1438. ()
  1439. # endif
  1440. {
  1441. }
  1442.  
  1443. static void yyExit
  1444. # ifdef __STDC__
  1445. ()
  1446. # else
  1447. ()
  1448. # endif
  1449. {
  1450.   IO_CloseIO();
  1451.   Exit(1L);
  1452. }
  1453.  
  1454. void BEGIN_GramC()
  1455. {
  1456.   static BOOLEAN has_been_called = FALSE;
  1457.  
  1458.   if (!has_been_called) {
  1459.     has_been_called = TRUE;
  1460.  
  1461.     BEGIN_IO();
  1462.     BEGIN_Tree();
  1463.     BEGIN_System();
  1464.     BEGIN_IO();
  1465.     BEGIN_Tree();
  1466.     BEGIN_IO();
  1467.     BEGIN_Strings();
  1468.     BEGIN_StringMem();
  1469.     BEGIN_Idents();
  1470.     BEGIN_Texts();
  1471.     BEGIN_Sets();
  1472.     BEGIN_TreeC2();
  1473.     BEGIN_Tree();
  1474.     BEGIN_Strings();
  1475.  
  1476.     GramC_yyf = IO_StdOutput;
  1477.     GramC_Exit = yyExit;
  1478.     GramC_BeginGramC();
  1479.   }
  1480. }
  1481.